Skip to content

feat: add MIDI glide for instrument & synth tracks - #131

Closed
z3phyr2 wants to merge 2 commits into
polyend:mainfrom
z3phyr2:feat/midi-glide
Closed

z3phyr2 wants to merge 2 commits into
polyend:mainfrom
z3phyr2:feat/midi-glide

Conversation

@z3phyr2

@z3phyr2 z3phyr2 commented Nov 22, 2026 •

Copy link
Copy Markdown

Summary & Goal

The Glide FX (G) currently only affects sample instruments. Patterns on MIDI instrument tracks (M01–M16) therefore cannot express legato/portamento-style note slides at all — you are dependent on the external synth's own portamento setting, which the pattern cannot control.

This PR makes the Glide FX work for MIDI instrument tracks. The behavior mirrors the sample-domain glide: the pitch slides from the previous note to the new note, with the duration taken from the G-FX value (the sample and MIDI paths now share the same time mapping). The feature is opt-in via a new config option that defaults to Off, so existing projects and workflows are unaffected. Sample tracks and the synth engine are untouched.

Behavior & Changes

New config item: Config > MIDI > "MIDI Glide" (controls MIDI instrument tracks M01–M16) with four modes:

  • Off (default) — no behavior change.
  • Legato — when the next note on the same row arrives while the previous note is still held, the previous note-off is deferred until just after the new note-on. Synths with portamento enabled trigger their native glide.
  • Bend — the glide is emulated in the MIDI stream with a linear pitch-bend ramp: a pitch-bend message is sent before the note-on, holding the new note at the pitch of the previous note; the bend then ramps linearly to center over the G-FX time, so the pitch slides from the old note to the new one. Works on any synth, independent of its portamento setting.
    • If the interval is wider than the assumed ±2 st bend range, the range is first widened via RPN 0,0 (pitch bend range), clamped to 2–24 st.
    • If the previous ramp is not finished yet, a new ramp starts from the current bend value, so no pitch jump occurs.
  • Both — legato reordering and pitch-bend ramp together. (On synths with native portamento the glide is applied twice — expected.)

Glide conditions (all modes):

  • The previous note on the same MIDI channel is still held, old and new note are MIDI notes on the same channel.
  • The new note has G FX > 0. Steps with the MIDI Chord FX (on old or new note) are excluded.
  • Ramp state is per channel (16 entries), stepped in the audio tick, and cleared on stop. A note-off of the ramped note cancels its ramp and returns the bend to center.

Additional details:

  • Sample tracks are unaffected. The glide time mapping (G 0–100 → 0–15 s) that the sample engine already used is extracted into a shared helper and reused by the MIDI path, so both domains map the FX value identically (sample behavior is unchanged).
  • The synth engine (S1–S3) is not touched — its native Voice-section glide works exactly as in stock firmware.
  • Existing projects and configs load unchanged; the new setting is appended to the MIDI config section and defaults to Off.

Target Devices

  • Original Polyend Tracker (MK66)
  • Polyend Tracker+ (IMX)
  • Polyend Tracker Mini (IMX)

Hardware Testing Status

Device Tested on Hardware by Author Needs Community Hardware Testing Not Applicable Notes / Tested By
Original Tracker (MK66) [ ] [x] [ ]
Tracker+ (IMX) [x] [ ] [ ] Author's test device — MIDI tracks (M01–M16) in all four modes incl. mute & stop behavior
Tracker Mini (IMX) [ ] [x] [ ]

How to Test

  1. Flash the .ptf for your device (Checks tab → polyend-tracker-ce-firmware artifact).
  2. Set Config > MIDI > "MIDI Glide" to Bend.
  3. In a pattern, place two consecutive notes on the same row of a MIDI track and give the second note a G FX value > 0 (e.g. 50). Play: the pitch slides from the first to the second note over the G-FX time.
  4. Switch to Legato: the slide now only happens on synths with portamento enabled (the note-off is deferred until after the note-on — visible in a MIDI monitor).
  5. MIDI monitor (USB MIDI into a DAW): in Bend mode you should see a pitch-bend message before the note-on, followed by the ramp; for intervals wider than 2 st, the RPN 0,0 range messages are sent first.
  6. Off restores the original off→on behavior, no pitch bend is sent.
  7. Mute the track while a glide is held → the held note releases immediately (no stuck notes); stopping playback resets all bend ramps to center.
  8. Sample tracks and synth tracks (S1–S3) behave exactly as in stock firmware.
  9. Open a project saved with an older firmware → everything loads unchanged.

The author has run the steps above on a Tracker+ (MIDI tracks M01–M16).

Developer Checklist

  • I have read and understood the Contribution & Pull Request Guidelines (CONTRIBUTING.md).
  • This PR implements one single feature or bug fix (no unrelated refactors or formatting sweeps).
  • make all compiles cleanly for all three devices (Original, Plus, Mini); make ptfx also verified locally (GNU Arm Embedded 10.3-2021.10, no new warnings).
  • Memory usage (SRAM_DTC, EXTERNAL_RAM, FLASH) was checked and stays within safe hardware headroom:
Device Region This PR Upstream reference (PR #128)
Original FLASH 902,168 B / 1 MB (86.04 %) —
Original EXTERNAL_RAM 15,688,008 B / 16 MB (93.51 %) 15,663,224 B (93.36 %)
Plus SRAM_DTC 346,208 B / 352 KB (96.05 %) 345,580 B (95.88 %)
Mini SRAM_DTC 344,552 B / 352 KB (95.59 %) 343,924 B (95.42 %)

(Delta vs. the reference build includes upstream commits merged after it; the feature itself adds ~600 B of fixed per-channel ramp state.)

  • No heap allocations (new/malloc) or SD card I/O were added to real-time audio callbacks.
  • Existing .mt projects, .pti instruments, .pts synth patches, and mtConfig settings remain backward-compatible.

The Glide FX (G) now also affects MIDI instrument tracks M01-M16 and
synth tracks S1-S3.

New config option Config > MIDI > "MIDI Glide":
- Off (default): no behavior change
- Legato: defer the previous note-off until after the new note-on,
  so synths with portamento trigger their native glide
- Bend: emulate the glide with a linear pitch-bend ramp sent before
  the note-on; RPN 0,0 widens the bend range to the interval when
  needed (MIDI tracks only); the ramp starts from the current bend
  value to avoid a jump when the previous ramp is unfinished
- Both: legato reordering + pitch-bend ramp

Glide only applies when the previous note on the same channel is
still held, G=0 keeps the original behavior, chords are excluded.
Sample tracks are unaffected; the sample glide time mapping is now
shared with the MIDI path via glideFxValueToMs().
Synth tracks (S1-S3) now always glide via the pitch-bend ramp when
G > 0, matching the sample-track behavior. The "MIDI Glide" config
option now only affects MIDI instrument tracks.
@github-actions

Copy link
Copy Markdown

Polyend Tracker CE Test Firmware & SD Card Content

This pull request passed all build checks. You can download and test the built firmware for Original Tracker, Tracker+, and Tracker Mini (Build: 0bfa458) and the matching SD card content (/System/) directly using the links below (no GitHub account required):

How to Install & Flash on Your Tracker

1. Flashing the Firmware (.ptf)

  1. Download and unzip polyend-tracker-ce-firmware.zip.
  2. Copy the .ptf file matching your hardware to the /Firmware/ folder on your Tracker's microSD card:
    • Original Polyend Tracker: PolyendTracker_CE_0bfa458.ptf
    • Polyend Tracker+: TrackerPlus_CE_0bfa458.ptf
    • Polyend Tracker Mini: TrackerMini_CE_0bfa458.ptf
  3. Insert the microSD card into your Tracker, navigate to Config → Firmware → Firmware update, select the .ptf file, and confirm.
  4. Once rebooted, you can verify you are running this PR build under Config → Firmware (Build: 0bfa458).

2. Installing SD Card Content (/System/)

  1. Download and unzip polyend-tracker-ce-sd-card.zip.
  2. Copy the System/ folder to the root directory of your Tracker's microSD card (you can optionally rename it to .system/ if you prefer it hidden).

3. Emergency Recovery (Just in Case)

The Tracker's bootloader is hardware-isolated from the firmware. If a test build ever fails to boot:

  1. Place a known-good, stable .ptf firmware file inside the /Firmware/ folder on your microSD card (ideally as the only .ptf file in that folder).
  2. Insert the microSD card and power on your Tracker.
  3. Use a paperclip or SIM-eject pin to press the recessed hardware Reset / Emergency Bootloader pinhole button (on the bottom of Original Tracker / Tracker+, or next to the USB-C port on Tracker Mini). The bootloader will automatically flash the .ptf file from /Firmware/.
Firmware File Sizes & Linker Memory Summary

Generated .ptf Firmware Files

-rw-r--r-- 1 runner runner 2.5M Nov 22 22:20 build/PolyendTracker_CE_712ca96.ptf
-rw-r--r-- 1 runner runner 3.7M Nov 22 22:24 build/TrackerMini_CE_712ca96.ptf
-rw-r--r-- 1 runner runner 3.6M Nov 22 22:23 build/TrackerPlus_CE_712ca96.ptf

Bundled .psyn Synth Engines (/System/Synths)

-rw-r--r-- 1 runner runner  67K Nov 22 22:24 build/System/Synths/ACD.psyn
-rw-r--r-- 1 runner runner  48K Nov 22 22:24 build/System/Synths/CHIP.psyn
-rw-r--r-- 1 runner runner  72K Nov 22 22:24 build/System/Synths/DIRT.psyn
-rw-r--r-- 1 runner runner  65K Nov 22 22:24 build/System/Synths/FAT.psyn
-rw-r--r-- 1 runner runner 114K Nov 22 22:24 build/System/Synths/PERC.psyn
-rw-r--r-- 1 runner runner  96K Nov 22 22:24 build/System/Synths/VAP.psyn
-rw-r--r-- 1 runner runner 124K Nov 22 22:24 build/System/Synths/WTFM.psyn

Generated .ptfx Sample Editor Effects (/System/Effects)

-rw-r--r-- 1 runner runner 1.2K Nov 22 22:24 editor-fx-sdk/build/System/Effects/add_silence.ptfx
-rw-r--r-- 1 runner runner 1.2K Nov 22 22:24 editor-fx-sdk/build/System/Effects/analog_kick_gen.ptfx
-rw-r--r-- 1 runner runner 2.9K Nov 22 22:24 editor-fx-sdk/build/System/Effects/chiptune_gen.ptfx
-rw-r--r-- 1 runner runner 5.9K Nov 22 22:24 editor-fx-sdk/build/System/Effects/convolution_reverb.ptfx
-rw-r--r-- 1 runner runner 2.9K Nov 22 22:24 editor-fx-sdk/build/System/Effects/cross_mod.ptfx
-rw-r--r-- 1 runner runner 1.4K Nov 22 22:24 editor-fx-sdk/build/System/Effects/haas.ptfx
-rw-r--r-- 1 runner runner 2.1K Nov 22 22:24 editor-fx-sdk/build/System/Effects/multimode_filter.ptfx
-rw-r--r-- 1 runner runner  13K Nov 22 22:24 editor-fx-sdk/build/System/Effects/speech_gen.ptfx
-rw-r--r-- 1 runner runner 2.5K Nov 22 22:24 editor-fx-sdk/build/System/Effects/stereo_delay.ptfx
-rw-r--r-- 1 runner runner 1.4K Nov 22 22:24 editor-fx-sdk/build/System/Effects/stereo_to_mono.ptfx
-rw-r--r-- 1 runner runner 2.0K Nov 22 22:24 editor-fx-sdk/build/System/Effects/transient_shaper.ptfx

Linker Memory Usage (All 3 Devices)

 Building Original Tracker (MK66) - CE 1.0.0 (712ca96)
source/Drivers/ExternalSdram.cpp: In member function 'bool ExternalSDRAM::testRamBlock(int, int*)':
   56 | bool ExternalSDRAM::testRamBlock(int blockIdx, int* const startAddress)
   56 | bool ExternalSDRAM::testRamBlock(int blockIdx, int* const startAddress)
Memory region         Used Size  Region Size  %age Used
           FLASH:      923516 B         1 MB     88.07%
             RAM:      181560 B       256 KB     69.26%
    EXTERNAL_RAM:    15686472 B        16 MB     93.50%
 Building Tracker+ (IMX) - CE 1.0.0 (712ca96)
Memory region         Used Size  Region Size  %age Used
      QSPI_FLASH:     1321044 B     16192 KB      7.97%
        SRAM_DTC:      347696 B       352 KB     96.46%
        SRAM_ITC:       63848 B     131064 B     48.72%
         SRAM_OC:       23212 B        32 KB     70.84%
    EXTERNAL_RAM:    67093512 B        64 MB     99.98%
 Building Tracker Mini (IMX) - CE 1.0.0 (712ca96)
Memory region         Used Size  Region Size  %age Used
      QSPI_FLASH:     1350964 B     16256 KB      8.12%
        SRAM_DTC:      346040 B       352 KB     96.00%
        SRAM_ITC:       63840 B     131064 B     48.71%
         SRAM_OC:       23212 B        32 KB     70.84%
    EXTERNAL_RAM:    67093512 B        64 MB     99.98%

@z3phyr2 z3phyr2 closed this Nov 22, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant